home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Small Eiffel 0.4.8 / lib_show / cecil / example1 / example.e < prev    next >
Encoding:
Text File  |  1997-04-13  |  1018 b   |  54 lines  |  [TEXT/ttxt]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class EXAMPLE
  5.    --
  6.    -- The Eiffel program is running first, then call the C program 
  7.    -- which is in charge to call the Eiffel feature `show_values'.
  8.    --
  9.    -- To compile this example, use command :
  10.    --   
  11.    --         compile -cecil cecil.se example c_prog.c
  12.    --
  13.    -- Is is also possible to do :
  14.    --
  15.    --         gcc -c c_prog.o
  16.    --         compile -cecil cecil.se example c_prog.o
  17.    --
  18.  
  19. creation make
  20.  
  21. feature
  22.  
  23.    make is
  24.       do
  25.      values := <<1,2,3>>;
  26.      call_c_prog(Current.to_pointer);
  27.       end;
  28.  
  29.    show_values is
  30.       local
  31.      i: INTEGER;
  32.       do
  33.      from
  34.         i := values.lower;
  35.      until
  36.         i > values.upper
  37.      loop
  38.         io.put_integer(values.item(i));
  39.         io.put_new_line;
  40.         i := i + 1;
  41.      end;
  42.       end;
  43.  
  44. feature {NONE}
  45.  
  46.    values: ARRAY[INTEGER];
  47.  
  48.    call_c_prog(current_object: POINTER) is
  49.       external "C"
  50.       alias "c_prog"
  51.       end;
  52.  
  53. end -- EXAMPLE
  54.